package com.bw.house.view

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
import com.bumptech.glide.request.target.DrawableImageViewTarget
import com.bw.base.view.BaseFragment
import com.bw.house.R
import com.bw.house.adapter.UserAdapter
import com.bw.house.databinding.FragmentUserBinding


class UserFragment : BaseFragment<FragmentUserBinding>() {

    private val adapter:UserAdapter= UserAdapter()
    data class User(
        val icon:Int,
        val title:String,
        val address:String
    )

    private val list:MutableList<User> = mutableListOf(
        User(icon = R.drawable.school_logo, title = "农夫山泉", address = "A区,107室"),
        User(icon = R.drawable.missa, title = "蜜雪冰城有限集团", address = "A区,111室"),
        User(icon = R.drawable.des, title = "网易云网络科技有限公司", address = "A区,104室"),
        User(icon = R.drawable.gogle, title = "谷歌有限公司", address = "A区,102室"),
        User(icon = R.drawable.oh, title = "华为科技有限公司", address = "A区,101室"),
        User(icon = R.drawable.windows, title = "微软科技有限公司", address = "A区,102室"),
        User(icon = R.drawable.xingbake, title = "星巴克有限公司", address = "A区,117室"),
    )



    override fun initView() {
        binding.rv.layoutManager=LinearLayoutManager(context)
        binding.rv.adapter=adapter
        binding.rv.addItemDecoration(DividerItemDecoration(context,DividerItemDecoration.VERTICAL))
    }

    override fun initData() {
        adapter.data.clear()
        adapter.data.addAll(list)
        adapter.notifyDataSetChanged()
    }


}